<template>
  <div>
    <div ref="node" class="node-item" :class="[nodeContainerClass]" :style="nodeContainerStyle">
      <div class="nodeName">{{ props.node.nodeName }}</div>
    </div>

  </div>
</template>
<script setup>
import { ref, onMounted, watch, nextTick, computed } from "vue";
import { nodeTypeNames } from "@/components/flowDesign/dicts/show.js";
const props = defineProps({
  node: {
    type: Object
  }
});
const node = ref(props.node)
const nodeContainerClass = computed(() => {
  var activeClass;
  return {
    "unselectable": props.node.nodeType == nodeTypeNames.finishNode ? true : false,
    "ef-node-container":
      props.node.nodeType != nodeTypeNames.initiatingNode ||
      props.node.nodeType != nodeTypeNames.finishNode,
    "ef-end-container":
      props.node.nodeType == nodeTypeNames.initiatingNode ||
      props.node.nodeType == nodeTypeNames.finishNode,
    "ef-groud-container":
      props.node.nodeType == nodeTypeNames.parallelBranchNode ||
      props.node.nodeType == nodeTypeNames.ifBranchNode,
  };
});
//     节点容器样式
const nodeContainerStyle = computed(() => {
  return {
    top: props.node.top,
    left: props.node.left,
  };
});
</script>
<style lang="less" scoped>
@labelColor: #409eff;
@nodeSize: 20px;
@viewSize: 10px;

.node-item {
  position: absolute;
  display: flex;
  height: 40px;
  width: 120px;
  justify-content: center;
  align-items: center;
  border: 1px solid #b7b6b6;
  border-radius: 4px;
  cursor: move;
  box-sizing: content-box;
  font-size: 12px;
  z-index: 9995;

  &:hover {
    z-index: 9998;

    .delete-btn {
      display: block;
    }
  }

  .log-wrap {
    width: 40px;
    height: 40px;
    border-right: 1px solid #b7b6b6;
  }

  .nodeName {
    flex-grow: 1;
    width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
  }

  .node-anchor {
    display: flex;
    position: absolute;
    width: @nodeSize;
    height: @nodeSize;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    cursor: crosshair;
    z-index: 9999;
    background: -webkit-radial-gradient(sandybrown 10%, white 30%, #9a54ff 60%);
  }

  .anchor-top {
    top: calc((@nodeSize / 2)*-1);
    left: 50%;
    margin-left: calc((@nodeSize/2)*-1);
  }

  .anchor-right {
    top: 50%;
    right: calc((@nodeSize / 2)*-1);
    margin-top: calc((@nodeSize / 2)*-1);
  }

  .anchor-bottom {
    bottom: calc((@nodeSize / 2)*-1);
    left: 50%;
    margin-left: calc((@nodeSize / 2)*-1);
  }

  .anchor-left {
    top: 50%;
    left: calc((@nodeSize / 2)*-1);
    margin-top: calc((@nodeSize / 2)*-1);
  }
}

.active {
  border: 1px dashed @labelColor;
  box-shadow: 0px 5px 9px 0px rgba(0, 0, 0, 0.5);
}

.common-circle-node {
  border-radius: 50%;
  height: 60px;
  width: 60px;
}
</style>